﻿using BasicInformation.ApiWrite.Application.Command.Location;
using BasicInformation.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicInformation.ApiWrite.Controllers
{
    /// <summary>
    /// 库位控制器——写
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    //[Authorize]
    public class LocationController : ControllerBase
    {
        private readonly IMediator mediator;

        public LocationController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加库位接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddLocation(AddLocationCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除库位接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<int>> DelLocation([FromQuery]DelLocationCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改库位接口
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> UpdateLocation(UpdateLocationCommand request)
        {
            return mediator.Send(request);
        }
    }
}
